package com.atchangsha.system.controller;

import java.util.Arrays;
import java.util.Map;
import org.springframework.web.bind.annotation.*;
import com.atchangsha.system.entity.AdminEntity;
import com.atchangsha.system.service.AdminService;
import com.atchangsha.system.common.utils.PageUtils;
import com.atchangsha.system.common.utils.Result;
import javax.annotation.Resource;

/**
 * 管理员表
 *
 * @author 卓越班项目第二组
 * @date 2022-05-15 11:46:30
 */
@RestController
@RequestMapping("system/admin")
public class AdminController {
    @Resource
    private AdminService adminService;

    /**
     * 列表
     */
    @GetMapping("/list")
    public Result list(@RequestParam Map<String, Object> params){
        PageUtils page = adminService.queryPage(params);
        return Result.ok().setResult(page);
    }


    /**
     * 信息
     */
    @GetMapping("/info/{id}")
    public Result info(@PathVariable("id") Long id){
		AdminEntity admin = adminService.getById(id);
        return Result.ok().setResult(admin);
    }

    /**
     * 保存
     */
    @PostMapping("/save")
    public Result save(@RequestBody AdminEntity admin){
		adminService.save(admin);
        return Result.ok();
    }

    /**
     * 修改
     */
    @PutMapping("/update")
    public Result update(@RequestBody AdminEntity admin){
		adminService.updateById(admin);
        return Result.ok();
    }

    /**
     * 删除
     */
    @DeleteMapping("/delete")
    public Result delete(@RequestParam Long[] ids){
		adminService.removeByIds(Arrays.asList(ids));
        return Result.ok();
    }

}
